package com.atgm.mall.gmmallclub.controller;

import com.atgm.common.utils.R;
import com.atgm.mall.gmmallclub.entity.CommentReplyEntity;
import com.atgm.mall.gmmallclub.service.CommentReplyService;
import com.atgm.mall.gmmallclub.vo.resp.CommentReplyRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("gmmallclub/commentreply")
public class CommentReplyController {

    @Autowired
    private CommentReplyService commentReplyService;

    @GetMapping("/getReplyInfo")
    public R getReplyInfo(@RequestParam Map<String, Object> param) {
        List<CommentReplyRespVo> list = commentReplyService.queryReplyInfo(param);
        return R.ok().setData(list);
    }

    /**
     * 给评论回复
     * @param commentReplyEntity
     * @return
     */
    @PostMapping("addReply")
    public R addReply(@RequestBody CommentReplyEntity commentReplyEntity) {
        commentReplyService.saveReplyInfo(commentReplyEntity);
        return R.ok();
    }

    @PutMapping("/updateThumbsCount/{id}/{count}")
    public R updateThumbsCount(@PathVariable("id") Long id, @PathVariable("count") Integer count) {
        commentReplyService.updateThumbsCountInfo(id, count);
        return R.ok();
    }



}
